<?php

class Usuarios_Form_Registro extends Zend_Form
{

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
    	$this->setName("registro");
    	$this->setMethod('post');
    	    	 
    	$nome = new Zend_Form_Element_Text('nome');
    	$nome->setLabel("Nome")
    	->setRequired(TRUE)
    	#->removeDecorator('htmlTag')
    	->setFilters(array("StripTags", "StringTrim"))
    	->setValidators(array("NotEmpty"))
    	;
    	 
    	$usuario = new Zend_Form_Element_Text('usuario');
    	$usuario->setLabel("Usuário")
    	->setRequired(TRUE)
    	#->removeDecorator('htmlTag')
    	->setFilters(array("StripTags", "StringTrim"))
    	->setValidators(array("NotEmpty"))
    	->addValidator('Db_NoRecordExists', false,
    			array(
    					'table' => 'usuarios',
    					'field' => 'usuario'
    			)
    	)
    	;
    	 
    	$senha = new Zend_Form_Element_Password('senha');
    	$senha->setLabel("Senha")
    	->setAttrib('size', 25)
    	->setRequired(TRUE)
    	->setFilters(array("StripTags", "StringTrim"))
    	#->removeDecorator('label')
    	#->removeDecorator('htmlTag')
    	->addValidators(array("NotEmpty"))
    	->addValidator('StringLength', false, array(4,25))
    	;
    	 
    	$vsenha = new Zend_Form_Element_Password('confirmsenha');
    	$vsenha->setLabel("Confirmar Senha")
    	->setAttrib('size', 25)
    	->setRequired(TRUE)
    	->setFilters(array("StripTags", "StringTrim"))
    	->removeDecorator('label')
    	#->removeDecorator('htmlTag')
    	->addValidators(array("NotEmpty"))
    	->addValidator('StringLength', false, array(4,25))
    	->addValidator('Identical', false, array('token' => 'senha'));
    	 
    	 
    	$permissao = new Zend_Form_Element_Hidden('id_perfil');
    	$permissao->removeDecorator('HtmlTag')
    	->setValue(0)
    	->removeDecorator('Label');
    	 
    	$enviar = new Zend_Form_Element_Submit("submit");
    	$enviar->setIgnore(true)
    	->setLabel("Registrar")
    	->removeDecorator('HtmlTag');
    	 
    	$token = new Zend_Form_Element_Hash('token');
    	$token->setSalt('s4a1t-53gur0')
    	->setTimeout(300)
    	->setIgnore(true)
    	->removeDecorator('HtmlTag')
    	->removeDecorator('Label')
    	->addErrorMessage(_('Token provided did not match, session expired. Please reload the form.'));
    	;
    	$this->addElements(array($nome, $usuario, $senha, $vsenha, $permissao, $enviar, $token));
    }


}

